package com.amrit.basic;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public enum SingletonEnum implements Cloneable {
	INSTANCE;
	public void print() {
		System.out.println("Singleton through ENUM");
	}

	public static void main(String[] args) throws CloneNotSupportedException {
		SingletonEnum singObj = SingletonEnum.INSTANCE;
		singObj.print();
		System.out.println(singObj);
		SingletonEnum anotherObj = SingletonEnum.INSTANCE;
		System.out.println(anotherObj);
		Map<String, Object> m = Collections
				.synchronizedMap(new HashMap<String, Object>(4));
		m.put("A", singObj);
		m.put("B", anotherObj);
		m.put(null, "BBC");
		m.put(null, "AAB");
		m.put("C", null);
		// m.put(null, null);
		System.out.println(m.get(null));
		// System.out.println(m.containsValue("AAB"));
		HashMap<String, Object> hm = new HashMap<String, Object>(m);
		hm.put("C", "CDE");
		// System.out.println("Map m is " + m);
		// System.out.println("Map hm is " + hm);
		// System.out.println("Clone of hm is " + hm.clone());
		// System.out.println(hm.keySet());
	}
}